import { loadRoutes } from "@/utils";

import MainLayout from "@/layout/mainLayout.vue";

import { appConfig } from "@/config";

import { MergeRoutes } from "../grand";

/*
 * sort: number  --- > 对路由进行排序
 * hiddenInMenu: boolean  ---- > 是否在左侧菜单显示
 * icon: string  --- > 菜单icon
 * key: string  --- > 与name相同
 * hiddenInBread: (false)  此级路由将不会出现在面包屑中
 * notAuth: true --- > 不需要权限
 */

// 一级路由path需要 /， 二级、下级不需要
const routes = new MergeRoutes(appConfig);
export const dynamicsRoutes = routes.setMergeRoutes([
    {
        path: "/system",
        name: "System",
        meta: {
            title: "系统设置",
            icon: "file-image",
        },
        redirect: {
            name: "Role",
        },
        component: MainLayout,
        children: loadRoutes(require.context("./system", false, /\.js$/)),
    },
    {
        path: "/components",
        name: "Components",
        meta: {
            title: "组件封装",
            icon: "picture",
        },
        redirect: {
            name: "ButtonComponents",
        },
        component: MainLayout,
        children: loadRoutes(require.context("./components", false, /\.js$/)),
    },
    {
        path: "/earlyWarning",
        name: "EarlyWarning",
        meta: {
            title: "预警管理",
            icon: "alert",
            notAuth: true,
        },
        redirect: {
            name: "EarlyHome",
        },
        component: MainLayout,
        children: loadRoutes(require.context("./earlyWarning", false, /\.js$/)),
    },
]);
